<template>
  <div>
    <my-breadcrumb :items="['板块中心', '闹钟管理']"/>
    <search :formItems="searchItems"  @search='getList' ref='getListSearch'  />
    <el-table :data="clocks" @sort-change="orderByTime">
      <el-table-column
        type="index"
        width="55">
      </el-table-column>
      <el-table-column
        type="selection"
        width="55">
      </el-table-column>
      <el-table-column
        label="创建时间"
        sortable="custom"
        prop="createtime">
      </el-table-column>
      <el-table-column
        label="用户名称"
        prop="membername">
      </el-table-column>
      <el-table-column
        label="商家名称"
        prop="businessname">
      </el-table-column>
      <el-table-column
        label="裙子名称"
        prop="skirtiname">
      </el-table-column>
      <el-table-column
        label="裙子状态"
        prop="skstatus">
        <template slot-scope="scope">
          {{ scope.row.skstatus === '0' ? '未过期' : '已过期' }}
        </template>
      </el-table-column>
      <el-table-column
        label="操作">
        <template slot-scope="scope">
          <!--<el-button size="mini" type="primary" @click="toUpdate(scope.row)">编辑</el-button>-->
          <el-button size="mini" type="text" @click="toDelete(scope.row.id)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import {deleteRow} from '../../utils/getList'
export default {
  name: 'clock',
  data () {
    return {
      searchItems: [
        {
          label: '用户名称',
          type: 'input',
          key: 'membername'
        },
        {
          label: '裙子',
          type: 'input',
          key: 'skirtiname'
        },
        {
          label: '商家名称',
          type: 'input',
          key: 'businessname'
        }
        // ,
        // {
        //   label: '商家',
        //   type: 'input',
        //   key: 'luckdrawcount'
        // }
      ],
      clocks: [],
      lifting: '1'
    }
  },
  methods: {
    getList () {
      let searchData = {}
      if (this.$refs['getListSearch']) {
        searchData = this.$refs['getListSearch'].search()
      }
      let params = {
        ...searchData,
        orderby: this.lifting
      }
      this.axios.get('/Remind/index', {params})
        .then(res => {
          if (res.data.status === 1) {
            this.clocks = res.data.data.list
          }
        })
    },
    toDelete (id) {
      deleteRow({url: '/Remind/delete', id}, res => {
        if (res.data.status === 1) {
          this.$message.success(res.data.msg)
          this.getList()
        }
      })
    },

    orderByTime (lifting) {
      if (lifting.order === 'ascending') {
        this.lifting = '2'
      } else {
        this.lifting = '1'
      }
      this.getList()
    }
  },
  created () {
    this.getList()
  }
}
</script>

<style scoped>

</style>
